package clientUtilGUI;

import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

import clientMain.Main;
import clientView.Excel;

public class Tab_Excel extends JToolBar implements ActionListener {
	private JButton btnExcel;
	private JButton btnWord;
	private JButton btnPDF;
	private JButton btnPPT;
	
	public Tab_Excel(){
		setFloatable(false);
		setOrientation(JToolBar.HORIZONTAL);
		setMargin(new Insets(0, 6, 0, 2));
		
		btnExcel = new JButton(UtilityGUI.subMenuReport, new ImageIcon("src/image/application_vnd_ms_excel.png"));
		btnExcel.setVerticalTextPosition(JButton.BOTTOM);
		btnExcel.setHorizontalTextPosition(JButton.CENTER);
		btnExcel.addActionListener(this);
		add(btnExcel);
		
		btnWord = new JButton("Word", new ImageIcon("src/image/Microsoft-Office-Word-48.png"));
		btnWord.setVerticalTextPosition(JButton.BOTTOM);
		btnWord.setHorizontalTextPosition(JButton.CENTER);
		btnWord.addActionListener(this);
		add(btnWord);
		
		btnPPT = new JButton("PPT", new ImageIcon("src/image/Microsoft Office PowerPoint.png"));
		btnPPT.setVerticalTextPosition(JButton.BOTTOM);
		btnPPT.setHorizontalTextPosition(JButton.CENTER);
		btnPPT.addActionListener(this);
		add(btnPPT);
		
		btnPDF = new JButton("PDF", new ImageIcon("src/image/Oficina-PDF-icon.png"));
		btnPDF.setVerticalTextPosition(JButton.BOTTOM);
		btnPDF.setHorizontalTextPosition(JButton.CENTER);
		btnPDF.addActionListener(this);
		add(btnPDF);
		
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnExcel){
			int index = Main.jTabbedPane.positionTab(UtilityGUI.tabReport);
			if(index == -1){
				Main.jTabbedPane.addTab(new Excel(), UtilityGUI.tabReport);
				Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
			}else{
				Main.jTabbedPane.setSelectedIndex(index);
				return;
			}
		}		
	}

}
